package modele;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.Collator;
import java.util.Comparator;

public class ComparatorDossierNom implements Comparator<Dossier>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2L;
	Collator myCollator = Collator.getInstance();
	public int compare(Dossier o1, Dossier o2){
		try {
			int res = (o1.getEtudiant().getNom()).compareTo(o2.getEtudiant().getNom());
			if (res ==0)
				res = (o1.getEtudiant().getPrenom()).compareTo(o2.getEtudiant().getPrenom());
			if (res ==0)
				res = (o1.getEtudiant().getIdApoflux()).compareTo(o2.getEtudiant().getIdApoflux());
			return res;
		}
		catch (Exception e){
			return 0;
		}
	}
	public boolean equals(Dossier o){
		try {
			return myCollator.equals(o.getEtudiant().getIdApoflux());
		}
		catch (Exception e){
			return false;
		}
	}
	private void writeObject(ObjectOutputStream out) throws IOException {
	}
	private void readObject(ObjectInputStream in) throws IOException {
	}
}
